import Vue from 'vue';
Vue.filter('controlLength',function(str, len){
  if (str.length > len) {
    return str.substr(0, len - 1) + "....";
  } else {
    return str;
  }
});
Vue.filter('toggleKeyNameOrAscii',function(asciiOrName){
  if (typeof asciiOrName == 'number') {
    switch (asciiOrName) {
      case 112 :
        return 'F1';
      case 113 :
        return 'F2';
      case 114 :
        return 'F3';
      case 115 :
        return 'F4';
      case 116 :
        return 'F5';
      case 117 :
        return 'F6';
      case 118 :
        return 'F7';
      case 119 :
        return 'F8';
      case 120 :
        return 'F9';
      case 121 :
        return 'F10';
      case 122 :
        return 'F11';
      case 123 :
        return 'F12';
    }
  } else if (typeof asciiOrName == 'string') {
    switch (asciiOrName) {
      case 'F1' :
        return 112;
      case 'F2':
        return 113;
      case 'F3':
        return 114;
      case 'F4' :
        return 115;
      case 'F5' :
        return 116;
      case 'F6' :
        return 117;
      case 'F7':
        return 118;
      case 'F8':
        return 119;
      case 'F9' :
        return 120;
      case 'F10' :
        return 121;
      case 'F11' :
        return 122;
      case 'F12':
        return 123;
    }
  }
  return asciiOrName;
});
